<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Dojo, javascript, integration, popup blocker, detection, fubar_perl" />
<meta name="description" content="Popup blocker detection using a simple javascript program and Dojo integration!" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta name="distribution" content="Global" />
<meta name="author" content="Dwight Vietzke" />
<meta http-equiv="Reply-to" content="dwight_vietzke@yahoo.com" />
<meta name="classification" content="mobile internet website software" />
<meta name="copyright" content="Copyright©2008-2009 - OpenSiteMobile" />

	<title>Popup Blocker Detection</title>

<script type="text/javascript" charset='utf-8' src="./msos/dojo_config.js"></script>
<script type="text/javascript" charset='utf-8' src="./dojo/dojo.js"></script>

<script type='text/javascript'>
/* <![CDATA[ */

dojo.require("msos.common");

var now = new Date;
var n_hour = zero_fill(now.getHours());
var n_min  = zero_fill(now.getMinutes());
var n_sec  = zero_fill(now.getSeconds());

function popup_test(){

	var popup = Object;
        var close_pop = null;
	var log1 = dojo.byId("p_1");
	var log2 = dojo.byId("p_2");

	log1.innerHTML = 'Attempting to run popup test';
	log2.innerHTML = 'Trying to open a small popup window.';

	// The following popup should trigger blocking if 'on'...
	popup = open('about:blank', 'Popup_test', 'height=100,width=200,scrollbars=no');

	// This was added for demo purposes
	if (djConfig.msos_popups_blocked) popup = null;
        
        close_pop = function () { if (popup.close) popup.close(); }

	var flag = 'ok';
	var str1= "Popup blocker detection results:<br />";
	var str2= 'Timestamp';

	if (popup) {
		var text = "<p>This is a popup test page, nothing more, and should close momentarily!<\/p>";
		popup.document.write(text);
		log1.innerHTML = 'Popup tested ok for creation!';
		log2.innerHTML = 'Attempting to write text to popup window.';
	}

	if(popup && !popup.closed){

		str1 += "<br />Object popup.open:<br />"	+ popup + "<br />";
		str1 += "<br />Object popup.document:<br />"	+ popup.document + "<br />";
		str1 += "<br />Object popup.closed:<br />"	+ popup.closed;

		if(msos.common.var_is_null(popup.document))	{ flag = 'blocked'; }
		if(msos.common.var_is_null(popup.closed))	{ flag = 'blocked'; }

		if(flag == 'blocked')	{ str1 += "<br /><br />It appears that popups are actively blocked!";	}
		else			{ str1 += "<br /><br />It appears that popups are not being blocked!";	}

                setTimeout(close_pop, 2000);

	} else { str1 += "<br />Popups are blocked!"; }
	
	log1.innerHTML = str1;
	log2.innerHTML = str2 + n_hour + n_min + n_sec;

	// This section is useful for testing and demo purposes.
	var config_ul = dojo.byId('configuration');
	config_ul.innerHTML = '';	// Clear na ref (for valid xhtml)
	for (var parm in djConfig) {
	    if (typeof(djConfig[parm]) == 'boolean') {
		var list_elm   = document.createElement("li");
		var inpt_elm_t = document.createElement("input");
		var inpt_elm_f = document.createElement("input");
		inpt_elm_t.type = "radio";
		inpt_elm_f.type = "radio";
		inpt_elm_t.name = parm;
		inpt_elm_f.name = parm;
		inpt_elm_t.value = 'true';
		inpt_elm_f.value = 'false';
		if (djConfig[parm])	inpt_elm_t.checked = true;
		else			inpt_elm_f.checked = true;
		var true_txt = document.createTextNode('T ');
		var list_txt = document.createTextNode('F ' + parm); 
		list_elm.appendChild(inpt_elm_t);
		list_elm.appendChild(true_txt);
		list_elm.appendChild(inpt_elm_f);
		list_elm.appendChild(list_txt);
		config_ul.appendChild(list_elm);
	    }
	}
}

function zero_fill(input) {
	if (input > 9)	{ return ':'  + input; }
	else		{ return ':0' + input; }
}

dojo.addOnLoad(popup_test);

/* ]]> */
</script>

<link rel="stylesheet" type='text/css' charset='utf-8' href="./msos/style/fubar.css" media='screen, handheld' />
<link rel='shortcut icon' href='./msos/images/osm.ico' />

</head>
<body>

<div id='body'>

<div class='marquee'>
    <img id='osm_logo_small' src='./msos/images/osm_logo_sml.jpg' class='marquee_img' alt="OpenSiteMobile" />
</div>

<div class='header'>
<a href='javascript: history.go(-1);' title='Return to the previous page'> Back </a>::
<a href='./index.html' title='Back to index page'> Home </a>
</div>

<h1>Popup Blocker Detection</h1>

<div class='pgrph'>
        This page is used for simple 'popup blocker' detection. It utilizes simple javascript
        to see if popups are allowed to be opened and closed via javascript or if popup blocking
        is stopping them!
</div>

<div id='p_1' class='pgrph_sml' style='white-space:pre;'>Popup Detection not available. Is JavaScript enabled?</div>

<div id='p_2' class='pgrph_sml'>Timestamp not available.</div>

<noscript>
<h2><span class='alert'>Your browser&#39;s JavaScript compiler is turned off or isn&#39;t available.</span></h2>

<p>You will need to enable JavaScript in your browser before popup testing will work!</p>
</noscript>

<h3>Page Debugging</h3>

<form accept-charset='utf-8' action='popup_detect.html' method='get'>
<div class='list_large'>

<ul id='configuration'><li>Not Available</li></ul>

<input type="submit" value="Reload Page" />

</div>
</form>

<h3 title='Testing utf-8 encoded characters'>Iñtërnâtiônàlizætiøn</h3>

<div class='footer'>
<a href='javascript: history.go(-1);' title='Return to the previous page'> Back </a>::
<a href='./index.html' title='Back to index page'> Home </a>
</div>

<div id='copyright'>
<span class='no_br'>Powered by:
   <a href='http://www.opensitemobile.com'>
  <span class='bold_text' title="Copyright©2008-2009 OpenSiteMobile - All rights reserved">MobileSiteOS</span></a>™</span>
</div>

</div> <!-- end 'body' div -->

</body>
</html>